<!DOCTYPE html>
<html lang="en">

<head>
    <!-- Use correct character set. -->
    <meta charset="utf-8">
    <!-- Tell IE to use the latest, best version. -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>Hello World!</title>
    <script src="../Build/Cesium/Cesium.js"></script>
    <style>
        @import url(../Build/Cesium/Widgets/widgets.css);
        html,
        body,
        #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
        
        #controls {
            position: absolute;
            left: 10px;
            top: 10px;
            color: #2ec5ad;
            border-radius: 5px;
            padding: 10px;
            background-color: rgba(38, 38, 38, 0.75);
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div id="credit"></div>
        <div id="cesiumContainer">
        <div id="cesiumxin" style="position:fixed;left:0;z-index:99"><a href="http://cesium.xin" style="color:aliceblue;text-decoration:none">cesium中文网 http://cesium.xin </a></div>
    </div>
    <div id="controls">
        添加图层
    </div>

    <script>
        var viewer = new Cesium.Viewer('cesiumContainer', {
            //2.????
            imageryProvider: new Cesium.SingleTileImageryProvider({
                url: '../img/worldimage.jpg'
            }),
            geocoder: false,
            //homeButton: false,
            sceneModePicker: false,
            baseLayerPicker: false,
            navigationHelpButton: false,
            animation: false,
            creditContainer: "credit",
            timeline: false,
            fullscreenButton: false,
            vrButton: false
        });

        document.getElementById('controls').onclick = function() {
            let tileInfo = prompt("请输入http://ip:port/*/tileset.json");
            var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
                url: tileInfo
            }));

            tileset.readyPromise.then(function() {
                var boundingSphere = tileset.boundingSphere;
                viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, boundingSphere.radius));
                viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
            }).otherwise(function(error) {
                throw (error);
            });
        }
    </script>
</body>

</html>